import Vue from 'vue'
import App from './App.vue'
import router from './router/router.js'
import './plugins/element.js'
//公共样式
import './assets/css/global.css'
import axios from 'axios'


//全局组件与样式
import VueQuillEditor from 'vue-quill-editor'
import TreeTable from 'vue-table-with-tree-grid'
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

//全局组件表格
Vue.component('tree-table',TreeTable);
Vue.use(VueQuillEditor);

//ajax请求跟路径
axios.defaults.baseURL = `http://127.0.0.1:8888/api/private/v1/`; //根路径
axios.interceptors.request.use((config)=>{
  config.headers.Authorization = window.sessionStorage.getItem('token');  //响应头
  return config;
});

//全局的时间过滤器
Vue.filter('dataFormat',(msg)=>{
  const dt = new Date(msg);
  const y = dt.getFullYear();
  const m = (dt.getMonth() + 1 + '').padStart(2,'0');
  const d = (dt.getDate() + '').padStart(2,'0');
  const hh = (dt.getHours() + '').padStart(2,'0');
  const ff = (dt.getMinutes() + '').padStart(2,'0');
  const ss = (dt.getSeconds() + '').padStart(2,'0');
  return `${y}-${m}-${d}-${hh}:${ff}:${ss}`;
})

//挂载全局ajax变量通过this.$http
Vue.prototype.$http = axios;


Vue.config.productionTip = false;

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
